define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/bets/index',
                    // add_url: 'user/bets/add',
                    // edit_url: 'user/bets/edit',
                    // del_url: 'user/bets/del',
                    multi_url: 'user/bets/multi',
                    table: 'bets',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'sequencenum', title: __('Sequencenum')},
                        {field: 'user.username', title: '会员账号'},
                        {field: 'content', title: __('Content'),operate:false},
                        {field: 'money', title: __('Money'), operate:'BETWEEN'},
                        {field: 'addtime', title: __('Addtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'game', title: __('Game'), searchList: {"lol":__('Game lol'),"pvp":__('Game pvp'),"dota2":__('Game dota2')}, formatter: Table.api.formatter.normal},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'ip', title: __('Ip'),operate:false},
                        {field: 'zj_money', title: __('Zj_money'), operate:'BETWEEN'},
                        {field: 'user.group_id', title: __('Role'), operate:false,searchList: {"1":'系统账号',"2":'玩家'}, formatter: Table.api.formatter.normal},
                        {field: 'createtime', title: '下注时间', operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field:'type','title':__('Type'),searchList: {"pk":__('Type pk'),"lottery":__('Type lottery')},formatter: Table.api.formatter.status}
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});